package com.hkbigdata.transfer;

import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.api.common.typeinfo.Types;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.util.Collector;

/**
 * @author liuanbo
 * @creat 2024-04-12-17:04
 * @see 2194550857@qq.com
 */
public class Flink02_TransForm_FlatMap_Anonymous {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);
        env.fromElements(1, 3, 4, 5, 6)
/*                .flatMap(
                new FlatMapFunction<Integer, Integer>() {
                    @Override
                    public void flatMap(Integer value, Collector<Integer> out) throws Exception {
                        out.collect(value * value);
                    }
                }
        ).print();*/
                .flatMap((Integer value, Collector<Integer> out) -> {
                    out.collect(value * value);
                }).returns(Types.INT).print();

        env.execute();
    }
}
